<template>
  <el-popover
    placement="top"
    title=""
    :width="width"
    ref="myPopover"
    trigger="click"
  >
    <div v-if="type=='Number'" style="display: flex">
    <el-input placeholder="请输入" v-model.number="input" >
    </el-input> <el-button @click="changeValue" style="margin-left: 10px" plain type="primary">确定</el-button></div>
    <div  v-else  style="display: flex">
    <el-input placeholder="请输入" v-model="input">
    </el-input><el-button @click="changeValue" style="margin-left: 10px" plain type="primary">确定</el-button></div>
    <el-button
      type="text"
      size="mini"
      icon="el-icon-edit"
      slot="reference"
    ></el-button>
  </el-popover>
</template>
<script>
export default {
  name:"EditCell",
  props: {
    id: {
      type: Number,
      default: 0
    },
    value: {
      type: [Number,String],
      default: ""
    },
    type:{
      type:String,
      default:"Number"
    },
    width:{
      type:String,
      default:"200"
    }
  },
  data() {
    return {
      input: this.value
    };
  },
  watch: {
    switchValue(val) {
      this.input = val;
    }
  },
  methods: {
    changeValue() {
      this.$refs["myPopover"].doClose();
      this.$emit("change", { id: this.id, value: this.input });
    }
  }
};
</script>
